<template>
	<div id="search">
		<div >
			<div >
				<i class="fa fa-search"></i>
				<input type="text"v-model="searchStr" />
			</div>
		</div>
		<h3>电影/电视剧/综艺</h3>
		<ul>
			<li v-for="(item,index) in results" :key="ndex"i>
				<div >
					<img :src="item.img" >
				</div>
				<div >
					<p>{{item.name}}</p>
					<p>{{item.actors}}</p>
					<p>{{item.nums}}</p>
				</div>
				<div v-if="item.id > 6 ">评分：{{item.score}}</div>
				<div v-else>{{item.score}}人想看</div>
			</li>
		</ul>
		
	</div>
</template>

<script>
	export default{
		name:"Search",
		data(){
			return{
				allData:[],
				searchStr:''
			}
		},
		methods:{
			getAll(){
				var that=this;
				function getComingPlayData(){
					return axios.get('/mock/comingPlayData.json');
				}
				
				function getNowPlayData(){
					return axios.get('/mock/getNowPlayData.json');
				}
				axios.all([getComingPlayData(),getNowPlayData()])
				.then(axios.spread(function(data1,data2){
					//
					//
					that.allData=[...data1.data.comingPlayData,...data2.data.nowPlayData];
					console.log(that.allData)
				}));
			}
		},
		created(){
			this.getAll()
		},
		computed:{
			results(){
				if(this.searchStr){
					return this.allData.filter(item=>item.name.includes(this.searchStr))
				}else{
					return[];
				}
				
			}
		}
	}
</script>

<style>
</style>
